package homework4221;

import java.io.FileOutputStream;
import java.io.IOException;

        public class Homework1 {
            public static void main(String[] args) {
                String content = "Hello world";
                FileOutputStream fos = null;
                try{
                    fos = new FileOutputStream("document/test.txt",true);
                    byte[] date =  content .getBytes("UTF-8");
                    fos.write(date);
                    fos.flush();
                    System.out.println("保存文件成功！");
                }catch (Exception ex){
                    ex.printStackTrace();
                }finally{
                    if(null != fos){
                        try {
                            fos.close();
                            fos = null;
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }

            }
        }


